package com.sixuerain.heartkey.prayer.base;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.os.PowerManager;
import android.os.Vibrator;
import android.view.WindowManager;

public class PrayerSysUtils {
	private static final String TAG = "PrayerSysUtils";

	private static PowerManager mPm;
	private static PowerManager.WakeLock mWakeLock;
    private static NotificationManager mNM;
	private static Vibrator mVibrator; 
	
	private static  Context mCtx;

	public PrayerSysUtils(Context ctx) {
		mCtx = ctx;
		mNM = (NotificationManager)mCtx.getSystemService(Context.NOTIFICATION_SERVICE);
		mPm = (PowerManager) mCtx
				.getSystemService(Context.POWER_SERVICE);
		mVibrator = (Vibrator) mCtx.getSystemService(mCtx.VIBRATOR_SERVICE);
		
	}
	
	public static NotificationManager getNotifiyMgr()
	{
		return mNM;
	}
	
	public static  void acquireWakeLock() {

		int wakeFlags;

		// if (mPedometerSettings.wakeAggressively()) {
		wakeFlags = PowerManager.SCREEN_DIM_WAKE_LOCK
				| PowerManager.ACQUIRE_CAUSES_WAKEUP;
		// }
		// else if (mPedometerSettings.keepScreenOn()) {
		// wakeFlags = PowerManager.SCREEN_DIM_WAKE_LOCK;
		// }
		// else {
		// wakeFlags = PowerManager.PARTIAL_WAKE_LOCK;
		// }
		mWakeLock = mPm.newWakeLock(wakeFlags, TAG);
		mWakeLock.acquire();
	}

	public static void releaseWakeLock() {

		mWakeLock.release();
	}
	
	public static void setWindow()
	{
		//SCREEN_BRIGHT_WAKE_LOCK
		// FLAG_DISMISS_KEYGUARD
		int flag = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
				WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
				;
				
		((Activity) mCtx).getWindow().addFlags(flag);
		
	//	((Activity) mCtx).getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
	//	((Activity) mCtx).getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
	}

}
